//
//  HistoryCell.m
//  YYPHSpeedJump
//
//  Created by sujiang on 15/12/28.
//  Copyright © 2015年 sujiang. All rights reserved.
//

#import "HistoryCell.h"

@implementation HistoryCell

- (void)awakeFromNib {
    // Initialization code
}
- (void)setModel:(HistoryModel *)model
{
    _model = model;
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    NSDate *start = [formatter dateFromString:model.start_time];
    NSDate *end= [formatter dateFromString:model.buy_time];
    NSTimeInterval time = [end timeIntervalSince1970] - [start timeIntervalSince1970];
    NSInteger min = time / 60;
    self.timeLb.text = [NSString stringWithFormat:@"%@ 用时:%ld分钟",model.buy_time, min+1];
    [self.goodPicView sd_setImageWithURL:[NSURL URLWithString:model.head_img_url] placeholderImage:nil];
    self.buyer.text = model.nickname;
    self.dealPrice.text = [NSString stringWithFormat:@"%@元",model.buy_price];
    self.nameLb.text = model.name;
    self.periodLb.text  =[NSString stringWithFormat:@"第%@期",model.period_num];
    self.saveMoney.text = [NSString stringWithFormat:@"%ld元", model.original_price.integerValue - model.buy_price.integerValue];
    self.peopleCount.text = [NSString stringWithFormat:@"%@人", model.join_users];
    self.orginalPrice.text = [NSString stringWithFormat:@"%@元", model.original_price];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
